package com.smommo.myapp.initialize;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;


//初始化接口，当Bean被实例化好后，会回调里面的函数，经常用于做一些加载资源的工作
//        销毁接口，当Bean被销毁之前，会回调里面的函数，经常用于做一些释放资源的工作
@Component
public class Animal implements InitializingBean, DisposableBean {

    //PostConstructor,preDestroy

    @PostConstruct
    public void initMethod()
    {
        System.out.println("animal.......initMethod......");
    }
    @PreDestroy
    public void DestroyMethod()
    {
        System.out.println("animal.......DestroyMethod......");
    }


    @Override
    public void destroy() throws Exception {
        System.out.println("animal.......destroy......");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("animal.......afterPropertiesSet......");

    }
}
